//
//  JJJBaseViewController.swift
//  myBlog
//
//  Created by 姜军君 on 15/11/26.
//  Copyright © 2015年 JJJ. All rights reserved.
//

import UIKit

class JJJBaseViewController: UITableViewController, vistorViewDelegate {
    
    // MARK: - 视图设置
    //    var userLogin = JJJUserAccount.loadUserAccount() != nil
    var userLogin = false
    
    var vistorView:JJJVistorView = JJJVistorView()
    
    override func loadView() {
        
        userLogin ? super.loadView() : setupVistorView()
    }
    
    /// 设置访客视图
    func setupVistorView() {
        
        view = vistorView
        vistorView.delegate = self
        
        setupNavgationBar()
    }
    
    /// 设置导航栏
    private func setupNavgationBar() {
        
//        navigationController?.navigationBar.tintColor = UIColor.orangeColor()
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorViewWillLogin")
    }
    
    // MARK: - 代理方法实现
    /// 登录
    func vistorViewWillLogin() {
        
        let oAuthNav = UINavigationController(rootViewController: JJJOAuthViewController())
        presentViewController(oAuthNav, animated: true, completion: nil)
    }
    
    /// 注册
    func vistorViewWillRegister() {
        print("注册")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }

}
